package com.shawn.jetpackstady.room;

import java.util.List;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.shawn.jetpackstady.room.bean.User;

@Dao
public interface UserDao {
    @Query("Select * from user Where userID = :id")
    User getUserById(int id);

    @Query("Select * from user Where Name = :name")
    User getUserByName(String name);

    @Query("Select * from user")
    List<User> getAll();

    @Query("Select * from user")
    LiveData<List<User>> loadAll();


    @Insert
    void insert(User user);

    // DELETE FROM 表名称 WHERE 列名称 = 值
    @Delete
    void delete(User name);

    @Update
    void update(User user);

}
